$(function(){
	$('input.easyui-validatebox').validatebox('disableValidation');
	$('input.easyui-combobox').combobox('disableValidation');
	initValidate();
});
function initValidate(){
	$.extend($.fn.validatebox.defaults.rules, {
		length: {
			validator: function(value, param){
				var length=$.trim(value).length;
				return length >= param[0]&&length <= param[1];
			},
			message: '字符长度必须在{0}到{1}之间'
	    },
	    minLength: {
			validator: function(value, param){
				return $.trim(value).length >= param[0];
			},
			message: '字符长度至少为{0}'
	    },
	    maxLength: {
			validator: function(value, param){
				return $.trim(value).length <= param[0];
			},
			message: '字符长度最多为{0}'
	    },
	    digits: {
			validator: function(value){
				return /^([1-9][0-9]*)$/.test(value);
			},
			message: '请输入合法整数'
	    },
	    phone:{
	    	validator: function(value){
				return /^(13[0-9]|15[0-9]|18[0-9]|14[0-9])[0-9]{8}$/.test(value);
			},
			message: '请输入合法电话'
	    },
	    money:{
	    	validator: function(value){
				return /^(((0|[1-9][0-9]*)\.[0-9]{1,2})|(0|[1-9][0-9]*))$/.test(value);
			},
			message: '请输入合法金额'
	    },
	    select:{
	    	validator: function(value){
				return (value!='请选择...')&&($.trim(value).length>0);
			},
			message: '请选择一个选项'
	    },
	    equals:{
	    	validator: function(value,param){
				return $(param[0]).val()==value;
			},
			message: '两次输入内容不一致'
	    }
	});
}

function formatDate(value){
	if(value==null){
		alert("dgjh");
		return null;
	}
	var date = new Date(value);
    var year = date.getFullYear().toString();
    var month = (date.getMonth() + 1);
    var day = date.getDate().toString();
    var hour = date.getHours().toString();
    var minutes = date.getMinutes().toString();
    var seconds = date.getSeconds().toString();
    if (month < 10) {
  	  month = "0" + month;
    }
    if (day < 10) {
        day = "0" + day;
    }
    if (hour < 10) {
        hour = "0" + hour;
    }
    if (minutes < 10) {
        minutes = "0" + minutes;
    }
    if (seconds < 10) {
       seconds = "0" + seconds;
    }
    return year + "-" + month + "-" + day + " " + hour + ":" + minutes + ":" + seconds;
}
